/**
 * 
 */
package com.lion.jacoco.biz;

import java.io.IOException;

import org.springframework.beans.factory.InitializingBean;

import com.lion.jacoco.common.GlobalVariable;
import com.lion.jacoco.common.PathUtil;

/**
 * GlobalVariableImpl.java. 2011-12-6下午12:07:23 @author LionBule.
 */
public class GlobalVariableImpl implements GlobalVariable,InitializingBean {
    private String reportPath;
    private String codePath;

    @Override
    public void afterPropertiesSet() throws Exception {
        fileStoreInit();
    }

    @Override
    public void fileStoreInit() {
        PathUtil.mkdirs(codePath);
        PathUtil.mkdirs(reportPath);
    }

    @Override
    public void clearAllCode() {
        try {
            PathUtil.del(codePath);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void clearAllReport() {
        try {
            PathUtil.del(reportPath);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void setReportPath(String reportPath) {
        this.reportPath = reportPath;
    }

    @Override
    public String getReportPath() {
        return reportPath;
    }

    @Override
    public String getCodePath() {
        return codePath;
    }

    public void setCodePath(String codePath) {
        this.codePath = codePath;
    }

}
